package com.itzdm.user.domain.dto;

import com.itzdm.common.exception.BadRequestException;
import com.itzdm.user.enums.LoginType;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;

@Data
@EqualsAndHashCode(callSuper=false)
public class UserLoginDto {
    @NotNull(message = "登录类型不能为空")
    private Integer loginType;
    private String email;
    private String tfId;
    private String password;
    private String code;

    public LoginType getLoginTypeEnum() {
        try {
            return LoginType.fromCode(loginType);
        } catch (IllegalArgumentException e) {
            throw new BadRequestException("不支持的登录类型: " + loginType);
        }
    }
}